
import bpy
import nodeitems_utils

import Core.bl_渲染层 as 渲染层
import 菜单.bl_ui_engine物体管理菜单 as 引擎菜单

from bpy.types import Operator, Menu





class C_节点创建子菜单_附加物体数据(Menu):
	bl_idname = "node.object_Attach_data"
	bl_label = "附加物体数据"

	def draw(self, context):
		layout = self.layout
		layout.operator("node.global_node_object_domain_add")
		layout.operator('node.global_node_object_voxel_add')
		layout.operator('node.global_node_voxelmask_add')
		#layout.operator('node.global_node_object_container_add')
		layout.operator('node.global_node_template_data_container_add')
		layout.operator('node.global_node_int_container_add')
		#layout.operator('node.global_node_int_container_get_element')
		
		
		

class C_节点创建子菜单_创建数据(Menu):
	bl_idname = "node.create_data"
	bl_label = "数据创建"
	
	def draw(self, context):
		layout = self.layout
		layout.menu("node.object_create_data")
		layout.menu("node.object_create_physics_data", icon='PHYSICS')
		layout.menu("node.texts_create_data", icon='ALIGN_FLUSH')
		




class C_节点创建子菜单_物理引擎(Menu):
	bl_idname = "node.physics_engine"
	bl_label = "物理引擎"

	def draw(self, context):
		layout = self.layout
		layout.menu("node.object_create_physics_engine_data_management")




class C_节点创建子菜单_物体(Menu):
	bl_idname = "node.object_edit_data"
	bl_label = "物体"

	def draw(self, context):
		layout = self.layout
		layout.operator("node.global_node_find_3x3x3_domain_guid")
		layout.operator('node.global_node_find_domain_guid_blocking_dir')
		
		layout.operator('node.global_node_intercept_object')
		layout.operator('node.global_node_obj_list_index')
		layout.operator('node.global_node_get_list_index_obj')

		layout.operator('node.global_node_set_object_show')
		layout.operator('node.global_node_set_object_keyframe_insert')


		#layout.operator('node.global_node_set_object_location')
		layout.separator()
		layout.operator('node.global_node_obj_modifiers')
		layout.menu('node.enum_object_edit', icon='PROPERTIES')
		layout.menu('node.enum_object_modifiers', icon='MODIFIER')
		layout.menu('node.enum_material_edit', icon='MATERIAL')
		
		
		layout.separator()
		layout.operator('node.global_node_object_trenform_keyframe_insert', icon='KEYTYPE_EXTREME_VEC')
		layout.operator('node.global_node_object_trenform_keyframe_clear', icon='HANDLETYPE_FREE_VEC')

		

class C_节点创建子菜单_节点更新(Menu):
	bl_idname = "node.update_node_data"
	bl_label = "节点更新"

	def draw(self, context):
		layout = self.layout
		layout.operator("node.global_node_object_frame_by_frame")
		layout.operator('node.global_node_manual_execution')
		layout.operator('node.global_node_switch_update_type')


class C_节点创建子菜单_数值(Menu):
	bl_idname = "node.update_value"
	bl_label = "数值节点"

	def draw(self, context):
		layout = self.layout
		layout.operator("node.global_node_single_random")
		layout.operator("node.global_node_single_mulit_random")
		layout.operator("node.global_node_list_mem_stack")
		layout.operator("node.global_node_float_list_mem_stack")
		layout.operator("node.global_node_vec_three_list_mem_stack")
		layout.operator("node.global_node_var_int")
		layout.operator("node.global_node_var_float")
		layout.operator("node.global_node_var_ivec3")
		layout.operator("node.global_node_var_vec3")
		layout.menu("node.var")
		

'''class C_节点创建子菜单_运算(Menu):
	bl_idname = "node.update_operation"
	bl_label = "运算控制节点"

	def draw(self, context):
		layout = self.layout

		layout.menu("node.math_operation")
		layout.menu("node.math_conversion")
		layout.menu("node.math_fun")
		layout.menu("node.math_geometric_calculation", icon='EVENT_G')
		
		#执行入口
		layout.operator("node.global_node_entrances")
		layout.operator("node.global_node_manual_execution")
		layout.operator("node.global_node_exec_update")
		'''


class C_节点创建子菜单_场景数据(Menu):
	bl_idname = "node.scene_data"
	bl_label = "场景数据"

	def draw(self, context):
		layout = self.layout
		#layout.operator("node.global_node_scene_frame")
		#layout.operator("node.global_node_getobj_prop_add")
		#layout.operator("node.global_node_get_one_dim_obj_prop_add")
		#layout.operator("node.global_node_get_two_dim_obj_prop_add")
		
		layout.menu("node.scene_prop", icon='PACKAGE')
		layout.menu("node.scene_objects_data")
		layout.menu("node.scene_objects")




class C_节点创建子菜单_辅助(Menu):
	bl_idname = "node.node_assist"
	bl_label = "辅助节点"
	
	def draw(self, context):
		layout = self.layout
		layout.operator("node.global_node_view_debug")


class C_节点创建子菜单_布局(Menu):
	bl_idname = "node.node_layout"
	bl_label = "布局"
	
	def draw(self, context):
		layout = self.layout
		#layout.operator("node.global_node_debug_info")
		#bpy.ops.node.add_node(type='NodeFrame', use_transform=True)
		layout.operator('node.add_node', text='添加框架').type = 'NodeFrame'
		layout.operator('node.group_make', text='添加组')
		layout.operator("node.global_node_container")
		


class C_节点创建子菜单_实例功能(Menu):
	bl_idname = "node.node_Instance_function"
	bl_label = "实例功能"
	
	def draw(self, context):
		layout = self.layout
		layout.operator('node.global_node_magic_cube_add')
		layout.operator('node.global_node_magic_iterator_cube_add')
		layout.operator('node.global_node_coord_point_the_rot_add')
		


classes = (
	C_节点创建子菜单_创建数据,
	C_节点创建子菜单_物理引擎,

	C_节点创建子菜单_附加物体数据,
	C_节点创建子菜单_物体,
	C_节点创建子菜单_节点更新,
	C_节点创建子菜单_数值,
	#C_节点创建子菜单_运算,

	C_节点创建子菜单_场景数据,

	C_节点创建子菜单_辅助,
	C_节点创建子菜单_布局,

	C_节点创建子菜单_实例功能,

)



def f_节点添加菜单func(self, context):
	if bpy.context.area.ui_type == 'idname_场景对象操作节点树':
		layout = self.layout

		layout.menu("node.menu_objects", icon='OBJECT_DATAMODE')
		layout.menu(C_节点创建子菜单_创建数据.bl_idname)
		
		
		layout.menu(C_节点创建子菜单_附加物体数据.bl_idname)
		layout.menu('node.menu_meshs', icon='OUTLINER_DATA_MESH')
		layout.menu("node.menu_container_data_operating", icon='PACKAGE')
		
		#layout.menu(C_节点创建子菜单_物体.bl_idname, text="编辑")
		
		layout.menu("node.menu_particle_system", icon='PARTICLE_DATA')
		layout.menu(C_节点创建子菜单_节点更新.bl_idname)
		#layout.menu('node.var', icon='LINENUMBERS_ON')
		layout.menu("node.menu_data", icon='LINENUMBERS_ON')
		
		#layout.menu(C_节点创建子菜单_运算.bl_idname, icon='FONTPREVIEW')
		layout.menu("node.menu_operation", icon='FONTPREVIEW')
		layout.menu("node.menu_material", icon='NODE_MATERIAL')

		layout.menu("node.menu_edit", text="编辑", icon='MODIFIER')
		layout.menu("node.node_control", icon='DECORATE_DRIVER')
		
		layout.menu(C_节点创建子菜单_场景数据.bl_idname, icon='SCENE_DATA')
		layout.menu("node.enum_geometry", icon='MESH_ICOSPHERE')
		#layout.menu(C_节点创建子菜单_物理引擎.bl_idname, icon='PHYSICS')
		layout.menu("node.menu_physics", icon='PHYSICS')
		layout.menu("node.menu_input", icon='STYLUS_PRESSURE')
		layout.menu("node.menu_script", icon='SCRIPTPLUGINS')
		#layout.menu(C_节点创建子菜单_辅助.bl_idname)
		layout.operator("node.global_node_view_debug", icon='SCENE_DATA')
		layout.menu(C_节点创建子菜单_布局.bl_idname)

		layout.menu(C_节点创建子菜单_实例功能.bl_idname)
		
	elif bpy.context.area.ui_type == 'idname_engine_场景对象管理节点树':
		layout = self.layout
		#layout.menu('node.menu_engine_objects_management', icon='SCENE_DATA')
		layout.menu('node.menu_engine_scene_objects', icon='SCENE_DATA')
		layout.menu("node.menu_engine_data_reception", icon='IMPORT')


def register():
	for c in classes:
		bpy.utils.register_class(c)

	渲染层.register()
	引擎菜单.register()
	print('f_节点添加菜单func')
	bpy.types.NODE_MT_add.append(f_节点添加菜单func)

def unregister():
	#bpy.types.NODE_MT_add.append(menu_draw_node_域)
	for c in classes:
		bpy.utils.unregister_class(c)

	渲染层.unregister()
	引擎菜单.unregister()






